package com.taxshare.operation.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.operation.service.ApiConsoleService;
import com.taxshare.operation.view.vo.ApiConsoleReqVO;
import com.taxshare.operation.view.vo.VisualRangeReqVO;
import com.taxshare.response.beans.Response;

@RestController
@RequestMapping(value = "/api/console")
@Api(tags = "【接口维护】-api")
public class ApiConsoleController {

	@Autowired
    private ApiConsoleService apiConsoleService;

	/**
     * 接口权限录入
     */
    @ApiOperation(value = "接口权限录入", notes = "接口权限录入")
    @PostMapping("/save")
    public Response saveApi(@RequestBody ApiConsoleReqVO reqVO) {
        return apiConsoleService.saveApi(reqVO);
    }

    /**
     * 接口权限列表展示-分页
     */
    @ApiOperation(value = "接口权限列表展示", notes = "接口权限列表展示")
    @PostMapping("/list")
    public Response<IPage<ApiConsoleReqVO>> queryPageList(@RequestBody PageRequest<ApiConsoleReqVO> apiInfoVO) {
        return apiConsoleService.queryPageList(apiInfoVO);
    }

    /**
     * 单条接口权限数据
     */
    @ApiOperation(value = "单条接口权限数据", notes = "单条接口权限数据")
    @PostMapping("/info")
    public Response showApiInfo(@RequestParam String uuid) {
        return apiConsoleService.showApiConsole(uuid);
    }

    /**
     * 更新接口权限
     */
    @ApiOperation(value = "可视范围修改", notes = "可视范围修改")
    @PostMapping("/update")
    public Response udpateApiInfo(@RequestBody VisualRangeReqVO reqVO) {
        return apiConsoleService.udpateApiInfo(reqVO);
    }


    /**
     * 删除接口权限
     */
    @ApiOperation(value = "删除接口权限", notes = "删除接口权限")
    @PostMapping("/delete/info")
    public Response deleteApiInfo(@RequestParam String uuid) {
        return apiConsoleService.deleteApiInfo(uuid);
    }
}
